/**
*一个加载中的动画,做成那个样子的
*太花费时间了，暂时不要用这个
 */
package kgame5.keff{
//import fl.motion.easing.*;
import kgame5.kgui.GP;
import kgame5.kmath.MathDG;
import kgame5.kutil.*;

import flash.display.*;
import flash.events.*;
import flash.geom.*;

public class EffLoading extends Sprite{
	
	static const BALL_RADIUS:int=3;//球的半径
	static const RADIUS:int=15;//总的半径
	
	static const DUR:Number=0.5;
	
	
	//______________________Property___________________
	
	
	private var count:int;
	
	
	private var speed:int=15;

	//______________________Method____________________
	public function EffLoading(p_count:int=8,p_speed:int=15){
		count=p_count;
		speed=p_speed;
		for(var i:int=0;i<count;i++){
			addBall(i);
		}
		
		this.visible=false;
	}
	
	public function start(){
		this.visible=true;
		addEventListener(Event.ENTER_FRAME,efh);
	}
	public function clear(){
		this.visible=false;
		removeEventListener(Event.ENTER_FRAME,efh);
	}
	
	private function addBall(idx:int){
		var mc_ball:MovieClip=new MovieClip();
		GP.drawArc(mc_ball.graphics, -1, 0xcccccc,0xcccccc, 0, 0, 0, 360, BALL_RADIUS, BALL_RADIUS);
		
		//mc_ball.idx=idx;//索引号，用来执行动画的
		mc_ball.myAngle=360/count*idx;
		var p:Point=Point.polar(RADIUS, MathDG.DTR*mc_ball.myAngle);
		mc_ball.x=p.x;
		mc_ball.y=p.y;
		
		mc_ball.alpha=1/count*(idx+1);
		
		//mc_ball.scaleX=mc_ball.scaleY=1/count*(idx+1);
		T.p(mc_ball.alpha);
		//aBall.push(mc_ball);
		this.addChild(mc_ball);
	}
	
	private function efh(e:Event){
		this.rotation+=speed;
		this.rotation%=360;
	}
}//end of class
}